<template>
  <div>
      <h1>添加患者信息</h1>
        <el-form :model="form" ref="form" :data="form" label-width="80px"  >
            <el-row>
                <el-col :span="16">
                    <el-form-item label="姓名" prop="name">
                        <el-input v-model="form.name" placeholder="姓名"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                <el-form-item label="性别">
                  <el-radio-group v-model="form.gender">
                    <el-radio :label="0">女</el-radio>
                    <el-radio :label="1">男</el-radio>
                  </el-radio-group>
                </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="16">
                    <el-form-item label="身份证号" prop="idCard">
                        <el-input v-model="form.idCard" placeholder="身份证号"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="年龄">
                    <el-input-number v-model="form.age"  :min="1" :max="99"></el-input-number>
                  </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="16">
                    <el-form-item label="电话号码" prop="phoneNumber">
                        <el-input v-model="form.phoneNumber" placeholder="电话号码"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="住院时间">
                        <el-date-picker v-model="form.value1" type="date" placeholder="住院日期"></el-date-picker>     
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="16">
                <el-form-item label="治疗医院">
                  <el-input v-model="form.hospital" placeholder="治疗医院"></el-input>
                </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="是否重症">
                    <el-radio-group v-model="form.sick">
                      <el-radio :label="0">否</el-radio>
                      <el-radio :label="1">是</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="16">
                  <el-form-item label="感染来源">
                    <el-input v-model="form.from" placeholder="感染来源"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="症状">
                    <el-input v-model="form.symptom" placeholder="症状"></el-input>
                  </el-form-item>
                </el-col>
            </el-row>
            <el-col :span="16">
            <el-form-item label="住址">
                <el-input v-model="form.address" placeholder="住址"></el-input>
            </el-form-item>
            </el-col>
            <el-col :span="16">
            <el-form-item label="备注">
                <el-input type="textarea" v-model="form.desc" rows="4" placeholder="备注"></el-input>
            </el-form-item>
            </el-col>
            <el-col :span="16">
            <el-form-item>
              <el-button type="primary">保存</el-button>
              <el-button>取消</el-button>
            </el-form-item>
            </el-col>
        </el-form>
    </div> 
</template>
<script>
import request from '@/utils/request'

export default {
  data() {
    return {
        pickerOptions: {
            disabledDate(time) {
                return time.getTime() > Date.now();
            },
          shortcuts: [{
            text: '今天',
            onClick(picker) {
              picker.$emit('pick', new Date());
            }
          }, {
            text: '昨天',
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24);
              picker.$emit('pick', date);
            }
          }, {
            text: '一周前',
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', date);
            }
          }]
        },
        input: '',
        tableData: null,
        currentPage1: 5,
        currentPage2: 5,
        currentPage3: 5,
        currentPage4: 4,
        dialogFormVisible: false,
              form: {
                date:'',
                desc:'',
                name:'',
                age:undefined,
                gender:1,
                phoneNumber:'',
                from:'',
                beginDate:'',
                homeAddress:'',
                address:'',
                },    
            formLabelWidth: '110px'
        }   
    },
    created(){
        this.fetchData()
    },
    methods:{
        fetchData(){
            request({
                url: '../close.json',
                method: 'get',   //发请求
            }).then(response => {
                this.tableData = response.data
            })
        },
        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
        },
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
        },
        handleEdit(){
          this.$router.push({
              path:'patient/add'
          })
      },
        },
        open() {
        this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
      }
    }

</script>